import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout
from PyQt5.QtWidgets import QPushButton, QLineEdit, QTextEdit


def init_widget(w: QWidget):
    # 创建垂直布局：vertical；创建水平布局：horizon
    layout = QHBoxLayout()

    btn1 = QPushButton("按钮1")
    btn2 = QPushButton("按钮2")
    btn2 = QPushButton("按钮2")
    btn3 = QPushButton("按钮3")
    btn4 = QPushButton("按钮4")

    btn1.clicked.connect(lambda: print("福建舰出港"))
    btn2.clicked.connect(lambda: print("舰载机起飞"))
    btn3.clicked.connect(lambda: print("巡航导弹就位"))
    btn4.clicked.connect(lambda: print("核潜艇出动"))

    layout.addWidget(btn1)
    layout.addWidget(btn2)
    layout.addWidget(btn3)
    layout.addWidget(btn4)

    w.setLayout(layout)


if __name__ == "__main__":
    # 1. 创建应用程序
    app = QApplication(sys.argv)

    # 2. 创建窗口
    w = QWidget()
    # 创建标题
    w.setWindowTitle("KZZ-260上位机")
    # w.resize(400, 300)

    init_widget(w)

    # 3. 显示窗口
    w.show()

    # 4. 等待APP停止
    sys.exit(app.exec_())
